<!DOCTYPE html>
<html>
<head>
    <title>枣阳市第二人民医院管理系统--中软高科2015</title>
	<meta charset="UTF-8">
   <link rel="stylesheet" type="text/css" href="Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="Css/style.css" />
    <script type="text/javascript" src="/Js/jquery.js"></script>
    <script type="text/javascript" src="Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="Js/bootstrap.js"></script>
    <script type="text/javascript" src="Js/ckform.js"></script>
    <script type="text/javascript" src="Js/common.js"></script>
    <style type="text/css">
        body {
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #f5f5f5;
        }

        .form-signin {
            max-width: 300px;
            padding: 19px 29px 29px;
            margin: 0 auto 20px;
            background-color: #fff;
            border: 1px solid #e5e5e5;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
        }

        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }

        .form-signin input[type="text"],
        .form-signin input[type="password"] {
            font-size: 16px;
            height: auto;
            margin-bottom: 15px;
            padding: 7px 9px;
        }

    </style>  
</head>
<body>
<div class="container">

    <form id="myForm" class="form-signin" method="post" action="pages/index.html#1/2">
        <h2 class="form-signin-heading">&nbsp;&nbsp;&nbsp;登录系统</h2>
        <input type="text" id="userName" name="userName" class="input-block-level" placeholder="账号">
        <input type="password" id="password" name="password" class="input-block-level" placeholder="密码">
        <input type="text" id="verify" name="verify" class="input-medium" placeholder="验证码">
        <button type="button" id="verifybtn" style="margin-left: 10px;border: none;background-color: white">获取验证码</button>
       
        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-large btn-primary" type="button" id="submit">登录</button></p>
    </form>

    <script>
        $(function (){

            var code = 0;
            $("#verifybtn").click(function(){
                $.ajax({
                    url:"/user/verifyCode",
                    type:"GET",
                    dataType:"json",
                    success:function (vo){
                        if(vo.statusCode==200){
                            code = vo.data;
                            $("#verifybtn").html(vo.data);
                        }else{
                            alert("获取验证码失败");
                        }
                    }
                })
            })

            $("#submit").click(function (){
                if($("#userName").val()==null || $("#userName").val().trim()==""){
                    alert("用户名不能为空");
                    return;
                }
                if($("#password").val()==null || $("#password").val().trim()==""){
                    alert("密码不能为空");
                    return;
                }
                if($("#verify").val()!=code){
                    alert("验证码不正确");
                    return;
                }
                alert($("#myForm").serialize()),
                $.ajax({
                    url:"/user/login",
                    data:$("#myForm").serialize(),
                    type:"GET",
                    dataType: "json",
                    success:function (vo){
                        if(vo.statusCode==200){
                           /* if(vo.data.roleId==1){
                                window.location.href = "/pages/index.html#1/2?userId="+vo.data.userId+"&userName="+vo.data.userLoginName+"&roleId="+vo.data.roleId;
                            }else if(vo.data.roleId==2){
                                window.location.href = "/pages/index.html#1/2?userId="+vo.data.userId+"&userName="+vo.data.userLoginName+"&roleId="+vo.data.roleId;
                            }else if(vo.data.roleId==3){
                                window.location.href = "/pages/index.html#1/5?userId="+vo.data.userId+"&userName="+vo.data.userLoginName+"&roleId="+vo.data.roleId;
                            }else if(vo.data.roleId==4){
                                window.location.href = "/pages/index.html#1/4?userId="+vo.data.userId+"&userName="+vo.data.userLoginName+"&roleId="+vo.data.roleId;
                            }else if(vo.data.roleId==5){
                                window.location.href = "/pages/index.html#1/16?userId="+vo.data.userId+"&userName="+vo.data.userLoginName+"&roleId="+vo.data.roleId;
                            }*/
                            console.log(vo.data);
                            window.location.href = "/pages/index.html";
                        }else{
                            alert(vo.msg);
                        }
                    }
                })
            })
        })
    </script>
</div>
</body>
</html>